package com.ceo.common.threadlocal;


import com.alibaba.ttl.TransmittableThreadLocal;
import com.ceo.common.vo.UserVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author uto_dev_008
 * @desc
 * @since 2021/11/24 10:57
 * Copyright (c)  All rights reserved
 */
public class ThreadEnvUtil {

    private static final Logger logger = LoggerFactory.getLogger(ThreadEnvUtil.class);

    protected static TransmittableThreadLocal<UserVo> userVoThreadLocal = new TransmittableThreadLocal<UserVo>() {
        protected UserVo initialValue() {
            return new UserVo();
        }
    };

    public static void SetUserObject(UserVo userVo) {
        userVoThreadLocal.set(userVo);
    }

    public static void clear() {
        userVoThreadLocal.remove();
        SetUserObject(new UserVo());

    }

    public static UserVo getUserObject() {
        UserVo userVo = userVoThreadLocal.get();
        return userVo;
    }
}
